require 'yaml'
require 'gookup/system/jars_loader'
class SettingsConatiner
  attr_reader :settings

  def initialize
    @settings={}
  end

  def [](symb)
    @settings[symb]
  end

  def []=(symb, value)
    @settings[symb]=value
  end

  def method_missing(m, *a) # enabling Setting.property
    @settings.send(m, *a)
  end

end

# will happen only once
if (!Object.const_defined?(:Settings))
  Settings=SettingsConatiner.new
  Settings[:output]="#{JENV.getProperty('user.home')}/.output/"
  if (!File.exists?(Settings[:output]))
    puts '# Creating default ouput path '+Settings[:output]
    Dir.mkdir(Settings[:output])
  end
  JarsLoader.new.load_jars
  YAML::load(File.open(File.dirname(__FILE__)+'/paths.yaml')).each_pair{|key, value| Settings[key.to_sym]=Settings.output+value}
end